/*
 * Created on 18.10.2006 by maxim
 */
package com.qjs.smterp.web.utils;

import javax.el.ELContext;
import javax.faces.context.FacesContext;

/**
 * @author maxim
 */
public class ManagedBeanWrapper {
    @SuppressWarnings("unchecked")
    public static <T> T getManagedBean(final String name) {
	// final StringBuilder sb = new
	// StringBuilder("#{").append(name).append("}");
	final ELContext elCtx = FacesContext.getCurrentInstance()
		.getELContext();
	final Object obj = elCtx.getELResolver().getValue(elCtx, null, name);

	if (null == obj) {
	    FacesContextUtils
		    .addInfoMessage("Managed bean " + name + " was not found."); 
	}
	return (T) obj;
    }
}
